<!-- BEGIN PAGE HEADER-->
<style>
    .ibox label {
        margin-left: 8px;
        margin-bottom: 8px;
    }
</style>
<?php $this->load->view('partials/breadcrumb.tpl', Array('_NO_IOSS_NEW' => '1')) ?>
<!-- END PAGE HEADER-->
<!-- BEGIN PAGE CONTENT-->
<script type="text/javascript">
    function defConfirm(url) {
        if (!confirm("确定要删除吗？")) {
            return false;
        }
        window.location.href = url;
        return true;
    }

    $(document).ready(function () {
        $("#reset").click(function () {
            $("select").val('');
            $("input[type='text']").val('');
        });
    });
</script>
<div class="row">
    <div class="col-xs-12">
        <!-- Begin: life time stats -->
        <div class="portlet">
            <?= form_open('', Array('class' => 'form-inline', 'role' => 'form')) ?>
            <?= search_form_input('task_id', filterValue('task_id'), '任务ID', 'class="form-control input-xs"'); ?>
            <?= search_form_input('order_no', filterValue('order_no'), '买家下单号', 'class="form-control input-xs"'); ?>
            <?php if ($this->_user->role_id == 1): ?>
                <?= search_form_dropdown('operator_id', array('' => '接单者...') + $allReviewsAdmin, filterValue('operator_id') ? filterValue('operator_id') : ($currentRoleId != 1 ? $currentAdminId : ''), '接单者', 'class="form-control input-xs"'); ?>
            <?php endif; ?>
            <?= search_form_dropdown('group_id', array('' => '所属销售组...') + $allSaleGroups, filterValue('group_id'), '所属销售组', 'class="form-control input-xs"'); ?>
            <?= search_form_dropdown('shop_id', array('' => '所属店铺...') + $allShops, filterValue('shop_id'), '所属店铺', 'class="form-control input-xs"'); ?>

            <?= search_form_dropdown('status', array('' => '选择状态...') + MTaskRecordItem::getState(), filterValue('status'), '状态', 'class="form-control input-xs"'); ?>
            <?= search_form_dropdown('payment_type', array('' => '选择付款类型...') + IOSS_StaticConfig::$payTypeArray, filterValue('payment_type'), '付款类型', 'class="form-control input-xs"'); ?>
            <?= search_form_dropdown('pay_method', array('' => '选择付款方式...') + IOSS_StaticConfig::getPayMethod(), filterValue('pay_method'), '打款方式', 'class="form-control input-xs"'); ?>
            <?= search_form_input('taskrecorditem_number_perpage', filterValue('taskrecorditem_number_perpage'), '每页显示条数', 'class="form-control input-xs"'); ?>
            <div style="clear:both;height:10px;"></div>

            <div class="input-group input-large date-picker input-daterange" data-date="" data-date-format="yyyy-mm-dd">
                <input type="text" class="form-control" name="task_record_item_create_time_begin" value="<?= filterValue('task_record_item_create_time_begin') ?>" placeholder="申请开始时间" autoComplete="off">
                <span class="input-group-addon">to</span>
                <input type="text" class="form-control" name="task_record_item_create_time_end" value="<?= filterValue('task_record_item_create_time_end') ?>" placeholder="申请结束时间" utoComplete="off">
            </div>

            <div class="input-group input-large date-picker input-daterange" data-date="" data-date-format="yyyy-mm-dd">
                <input type="text" class="form-control" name="task_record_item_update_time_begin" value="<?= filterValue('task_record_item_update_time_begin') ?>" placeholder="处理开始时间" autoComplete="off">
                <span class="input-group-addon">to </span>
                <input type="text" class="form-control" name="task_record_item_update_time_end" value="<?= filterValue('task_record_item_update_time_end') ?>" placeholder="处理结束时间" autoComplete="off">
            </div>
            <label style="float: right;margin-right: 20px" class="label label-danger">总计<?= $total_number ?>条</label>
            <button type="button" class="btn default" id="reset">重置条件</button>
            <button type="submit" class="btn green about_search">搜索 <i class="fa fa-search"></i></button>
            <!--            <button type="button" class="btn purple" onclick="iBox()">导出选项</button>-->
            <?php if(in_array($this->_user->role_id,[2,3,4,5])): ?>
                <button id="ajax_merge" type="button" class="btn red">合并提交</button>
                <?php if($this->session->userdata('PAY_REQUEST_CEPING_IDS')):?>
                    <a class="btn yellow" href="<?=site_url('finance/apply/add')?>">上次预导出历史</a>
                <?php endif;?>
            <?php endif; ?>
            <button type="button" class="btn purple" id="export-xls">原版导出</button>
            <button type="button" class="btn red" id="export-xls-python">快速导出</button>
            <button id="import_xls" type="button" class="btn blue">测评导入</button>

            <script>
                function iBox() {
                    $('#choose-field').toggle(500, 'swing')
                }

                $("#import_xls").click(function () {
                    $("#importModal").modal();
                });
            </script>
            <?= form_close() ?>
            <div style="display:none;" class="portlet-body" id="choose-field">
                <form action="" method="post" id="export_form">
                    <div class="well well-sm" style="margin: 10px 0;">
                        <div class="checkbox" style="margin-bottom: 15px;">
                            <b><i>请选择要导出的字段：</i></b>
                            <label>
                                <input id="all" type="checkbox">
                                全选/全不选
                            </label>
                        </div>
                        <div class="checkbox ibox">
                            <label>
                                <input class="fbox" checked name="field[]" value="id" type="checkbox">id
                            </label>
                            <label>
                                <input class="fbox" checked name="field[]" value="operator_id" type="checkbox">接单人
                            </label>
                            <label>
                                <input class="fbox" checked name="field[]" value="task_id" type="checkbox">所属任务
                            </label>
                            <label>
                                <input class="fbox" checked name="field[]" value="asin" type="checkbox">任务sain
                            </label>
                            <label>
                                <input class="fbox" checked name="field[]" value="product_image" type="checkbox">任务图片
                            </label>
                            <label>
                                <input class="fbox" checked name="field[]" value="comment_link" type="checkbox">评论连接
                            </label>
                            <label>
                                <input class="fbox" checked name="field[]" value="shop_id" type="checkbox">店铺
                            </label>
                            <label>
                                <input class="fbox" checked name="field[]" value="order_no" type="checkbox">订单编号
                            </label>
                            <label>
                                <input class="fbox" checked name="field[]" value="buyer_order_time" type="checkbox">买手下单时间
                            </label>
                            <label>
                                <input class="fbox" checked name="field[]" value="buyer_pay_time" type="checkbox">买手付款时间
                            </label>
                            <label>
                                <input class="fbox" checked name="field[]" value="true_product_price" type="checkbox">购买时商品价格
                            </label>
                            <label>
                                <input class="fbox" checked name="field[]" value="buyer_pay_total" type="checkbox">买手下单支付费用
                            </label>
                            <label>
                                <input class="fbox" checked name="field[]" value="buyer_pay_coin_type" type="checkbox">买家付款币种
                            </label>
                            <label>
                                <input class="fbox" checked name="field[]" value="payment_type" type="checkbox">打款类型
                            </label>
                            <label>
                                <input class="fbox" checked name="field[]" value="pay_method" type="checkbox">付款方式
                            </label>
                            <label>
                                <input class="fbox" checked name="field[]" value="contact" type="checkbox">收款联系方式
                            </label>
                            <label>
                                <input class="fbox" checked name="field[]" value="pay_account" type="checkbox">收款账户
                            </label>
                            <label>
                                <input class="fbox" checked name="field[]" value="bank" type="checkbox">开户行信息
                            </label>
                            <label>
                                <input class="fbox" checked name="field[]" value="amount" type="checkbox">应付金额
                            </label>
                            <label>
                                <input class="fbox" checked name="field[]" value="coin_type" type="checkbox">应付币种
                            </label>
                            <label>
                                <input class="fbox" checked name="field[]" value="rate_rmb" type="checkbox">对人民币汇率
                            </label>
                            <label>
                                <input class="fbox" checked name="field[]" value="add_image" type="checkbox">凭证
                            </label>
                            <label>
                                <input class="fbox" checked name="field[]" value="add_image_1" type="checkbox">凭证1
                            </label>
                            <label>
                                <input class="fbox" checked name="field[]" value="add_image_2" type="checkbox">凭证2
                            </label>
                            <label>
                                <input class="fbox" checked name="field[]" value="finance_id" type="checkbox">财务处理者
                            </label>
                            <label>
                                <input class="fbox" checked name="field[]" value="status" type="checkbox">状态
                            </label>
                            <label>
                                <input class="fbox" checked name="field[]" value="remark" type="checkbox">备注
                            </label>
                            <label>
                                <input class="fbox" checked name="field[]" value="create_time" type="checkbox">创建时间
                            </label>
                            <label>
                                <input class="fbox" checked name="field[]" value="update_time" type="checkbox">更新时间
                            </label>
                            <input type="hidden" name="file_name" value="ce_ping_">
                            <input type="hidden" name="page_name" value="tasks.taskrecorditem.index">
                            <input type="hidden" name="excel_type" value="TaskRecordItemExport">
                        </div>
                        <div class="text-right">
                            <button id="export-xls" type="button" class="text-right btn blue-madison">导出xls</button>
                        </div>
                        <script>
                            $('#export-xls').click(function () {
                                var data = $('#export_form').serialize();
                                if (data.indexOf('field') == -1) {
                                    toastr.error('请选择要导出的字段！', '失败');
                                    return false;
                                } else {
                                    var x = 1;
                                    var y = 1;
                                    $('#process').modal('show');
                                    setInterval(function () {
                                        x += parseFloat(Math.random(0, 1));
                                        var width = x.toFixed(2) + '%';
                                        if (parseInt(x) >= 99) {
                                            x = y / (y + 1) * 100;
                                            y++;
                                        }
                                        $('#show-process').html(width);
                                        $('#show-process').css('width', width)
                                    }, 1000);
                                    $.ajax({
                                        url: '<?=site_url("/common/ExcelExport/excel_export")?>',
                                        data: data,
                                        method: 'POST',
                                        dataType: 'json',
                                        success: function (output) {
                                            console.log(output)
                                            clearInterval();
                                            $('#show-process').html('100%');
                                            $('#show-process').css('width', '100%');
                                            $('#process').modal('hide');
                                            toastr.success(output.msg, '成功');
                                            document.location.href = '/' + output.url;
                                        },
                                        fail: function (data) {
                                            toastr.error(data.msg, '失败')
                                        }
                                    })
                                }
                            });

                            $('#export-xls-python').click(function () {
                                var data = $('#export_form').serialize();
                                if (data.indexOf('field') == -1) {
                                    toastr.error('请选择要导出的字段！', '失败');
                                    return false;
                                } else {
                                    var x = 1;
                                    var y = 1;
                                    $('#process').modal('show');
                                    setInterval(function () {
                                        x += parseFloat(Math.random(0, 1));
                                        var width = x.toFixed(2) + '%';
                                        if (parseInt(x) >= 99) {
                                            x = y / (y + 1) * 100;
                                            y++;
                                        }
                                        $('#show-process').html(width);
                                        $('#show-process').css('width', width)
                                    }, 1000);
                                    $.ajax({
                                        url: '<?=site_url("/common/ExcelExport/python_export")?>',
                                        data: data,
                                        method: 'POST',
                                        dataType: 'json',
                                        success: function (output) {
                                            console.log(output)
                                            clearInterval();
                                            $('#show-process').html('100%');
                                            $('#show-process').css('width', '100%');
                                            $('#process').modal('hide');
                                            if(output.status){
                                                toastr.success(output.msg, '成功');
                                            }else{
                                                toastr.error(output.msg, '失败');
                                            }
                                            document.location.href = '/' + output.url;
                                        },
                                        fail: function (data) {
                                            toastr.error(data.msg, '失败')
                                        }
                                    })
                                }
                            });

                            $('#all').click(function () {
                                if ($(this).prop("checked") == true) {
                                    $(".fbox").prop('checked', true);
                                    $(".fbox").parent('span').addClass('checked');
                                    return;
                                } else {
                                    $(".fbox").prop('checked', false);
                                    $(".fbox").parent('span').removeClass('checked');
                                    return;
                                }
                            });
                        </script>
                    </div>
                </form>
            </div>
            <div class="portlet-body">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="table-scrollable">
                            <form id="ajax_merge_form" action="" method="post" onsubmit="return false">
                                <div>

                                    <button id="ajax_delete" type="button" class="btn red"><i class="fa fa-trash-o"></i>批量删除</button>
                                </div>
                                <table class="table table-hover table-bordered table-striped">
                                    <thead>
                                    <tr>
                                        <th width="1%">
                                            <label>
                                                <input type="checkbox" id="merge_all" ">
                                            </label>
                                        </th>
                                        <th width="3%">ID</th>
                                        <th width="5%">记录ID</th>
                                        <th width="5%">任务ID</th>
                                        <th width="6%">商品名称</th>
                                        <th width="8%">店铺</th>
                                        <th width="5%">接单者</th>
                                        <th width="6%">下单号</th>
                                        <th width="4%">收款人</th>
                                        <th width="6%">收款账号</th>
                                        <th width="4%">汇率</th>
                                        <th width="6%">应付金额</th>
                                        <th width="4%">付款类型</th>
                                        <th width="4%">付款方式</th>
                                        <th width="3%">状态</th>
                                        <th width="5%">创建时间</th>
                                        <th width="5%">更新时间</th>
                                        <th width="4%">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <?php foreach ($list as $v) { ?>
                                        <tr>
                                            <td>
                                                <input type="checkbox" class="mbox" name="ceping_ids[]"
                                                       value="<?= $v->id ?>" title="ID:<?= $v->id ?>">
                                            </td>
                                            <td><?= $v->id ?></td>
                                            <td><?= $v->record_id ?> - <a style="background:#e20000;color:#fff;padding:2px 5px;" href="javascript:ioss_url_modal('<?= site_url('/tasks/taskrecords/ajaxViewDetail/' . $v->record_id) ?>');">查看</a></td>
                                            <td><?= $v->task_id ?> - <a style="background:#00a200;color:#fff;padding:2px 5px;" href="<?=site_url('/tasks/task/view/'.$v->task_id);?>">查看</a></td>
                                            <td> <?= $v->product_name ?> </td>
                                            <td><?= $allShops[$v->shop_id] ?></td>
                                            <td><?= $allReviewsAdmin[$v->operator_id]; ?></td>
                                            <td><?= $v->order_no ?></td>
                                            <td><?= htmlspecialchars($v->contact) ?></td>
                                            <td><?= htmlspecialchars($v->pay_account) ?></td>
                                            <td class="<?php if (in_array($v->status, [0, 2])): echo 'change-rate'; endif; ?>" data-item_id="<?= $v->id ?>"><?= htmlspecialchars($v->rate_rmb) ?></td>
                                            <td class="<?php if (in_array($v->status, [0, 2])): echo 'change-amount'; endif; ?>" data-coin="<?= IOSS_StaticConfig::getcoinTypeInfo($v->coin_type) ?>" data-item_id="<?= $v->id ?>"><?= number_format($v->amount, 2, '.', '') ?> (<?= IOSS_StaticConfig::getcoinTypeInfo($v->coin_type) ?>)</td>
                                            <td><?= IOSS_StaticConfig::getPayTypeInfo($v->payment_type) ?></td>
                                            <td><?= IOSS_StaticConfig::getPayMethod($v->pay_method); ?></td>
                                            <td class="text-center"><?= MTaskRecordItem::getState($v->status); ?></td>
                                            <td><?= date('Y-m-d H:i:s', $v->create_time) ?></td>
                                            <td><?= date('Y-m-d H:i:s', $v->update_time) ?></td>
                                            <td>
                                                <a href="javascript:ioss_url_modal('<?= site_url('/tasks/taskrecorditem/ajaxViewDetail/' . $v->id) ?>');"
                                                   class="btn btn-sm blue <?= $p->read ? '' : 'disabled' ?>">
                                                    <i class="fa fa-play"></i> 查看</a>
                                            </td>
                                        </tr>
                                    <?php } ?>
                                    </tbody>
                                </table>
                            </form>
                        </div>
                    </div>
                </div>
                <script>
                    function ajaxRequest(url, data, successCallback){
                        $.ajax({
                            url: url,
                            method: 'POST',
                            dataType: 'JSON',
                            data: data,
                            success: function (res) {
                                successCallback(res);
                            },
                            fail: function (res) {
                                toastr.error('网络错误，请稍后重试');
                                console.log(res)
                            }
                        })
                    }

                    // ajax修改汇率
                    $(".change-rate").dblclick(function (e) {
                        var item_id = e.currentTarget.dataset.item_id;
                        var html = "<input data-rate='"+ $(this).html() +"' data-item_id='"+item_id+"' autofocus='autofocus' type='number' min='0' max='100' step='0.001' class='rate-input' style='width:60px' name='rate' value='" + $(this).html()  + "' />";
                        $(this).html(html);
                    });
                    $('body').on("blur", ".rate-input",function (e) {
                        var this_ = this;
                        $(this_).attr('disabled','disabled');
                        var old_rate = e.currentTarget.dataset.rate, item_id = e.currentTarget.dataset.item_id;
                        var new_rate = this.value;
                        var data = {
                            'id': item_id,
                            'value': new_rate,
                            'type': 'rate'
                        };
                        ajaxRequest("<?= site_url('tasks/taskrecorditem/ajaxEdit') ?>", data, function (res) {
                            console.log(res);
                            if (res.status){
                                $(this_).parents('.change-rate').html(new_rate);
                            } else {
                                toastr.error(res.msg);
                                $(this_).parents('.change-rate').html(old_rate);
                            }
                        });
                    });

                    // ajax修改金额
                    $(".change-amount").dblclick(function (e) {
                        var item_id = e.currentTarget.dataset.item_id, coin = e.currentTarget.dataset.coin;
                        var html = "<input data-coin='"+ coin +"' data-amount='"+ parseFloat($(this).html()) +"' data-item_id='"+item_id+"' autofocus='autofocus' type='number' min='0' max='100000' step='0.001' class='amount-input' style='width:60px' name='rate' value='" + parseFloat($(this).html()) + "' />";
                        $(this).html(html + '(' + coin + ')');
                    });
                    $('body').on("blur", ".amount-input",function (e) {
                        var this_ = this;
                        $(this_).attr('disabled','disabled');
                        var item_id = e.currentTarget.dataset.item_id, old_amount = e.currentTarget.dataset.amount, coin = e.currentTarget.dataset.coin;;
                        var new_value = this.value;
                        var data = {
                            'id': item_id,
                            'value' :new_value,
                            'type': 'amount'
                        };
                        ajaxRequest("<?= site_url('tasks/taskrecorditem/ajaxEdit') ?>", data, function (res) {
                            console.log(res);
                            if (res.status){
                                $(this_).parents('.change-amount').html(new_value + '(' + coin + ')');
                            } else {
                                toastr.error(res.msg);
                                $(this_).parents('.change-amount').html(old_amount + '(' + coin + ')');
                            }
                        });
                    })
                </script>
                <div class="row">
                    <div class="col-xs-12 text-right">
                        <?= $pagination ?>
                    </div>
                </div>
            </div>
        </div>
        <!-- End: life time stats -->
    </div>
</div>

<div class="modal fade" id="importModal">
    <div class="modal-dialog" role="document">
        <form method="post" action="" enctype="multipart/form-data">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title" id="exampleModalLabel">测评导入</h4>
                </div>
                <div class="modal-body">
                    <p>点击此处下载表格模板文件 <b><a style="color: #3a5aff;" href="/upload/new_example.xlsx">导入模板.xlsx</a><span style="color: red;">   （必须使用此表格进入导入操作！）</span></b>
                    </p>
                    <div class="col-md-12">
                        <p style="color: #ff3761;">*时间格式：</p>
                        <ul>
                            <li><b> 年/月/日，例如 2019/5/6 </b></li>
                        </ul>
                    </div>
                    <div class="col-md-12">
                        <p style="color: #ff3761;">*付款方式对照：</p>
                        <ul>
                            <li><b> 1 => PayPal</b></li>
                            <li><b> 2 => 银联</b></li>
                            <li><b> 3 => 支付宝</b></li>
                            <li><b> 4 => 微信</b></li>
                            <li><b> 5 => 代付</b></li>
                        </ul>
                    </div>
                    <div class="col-md-12">
                        <p style="color: #ff3761;">*币种对照：</p>
                        <ul>
                            <li><b> 1 => 美元</b></li>
                            <li><b> 2 => 欧元</b></li>
                            <li><b> 3 => RMB</b></li>
                            <li><b> 4 => 英镑</b></li>
                            <li><b> 5 => 日元</b></li>
                            <li><b> 6 => 加元</b></li>
                        </ul>
                    </div>
                    <div class="col-md-12">
                        <p style="color: #ff3761;">*国家对照：</p>
                        <ul>
                            <li><b> DE => 德国</b></li>
                            <li><b> FR => 法国</b></li>
                            <li><b> UK => 英国</b></li>
                            <li><b> IT => 意大利</b></li>
                            <li><b> ES => 西班牙</b></li>
                            <li><b> JP => 日本</b></li>
                            <li><b> US => 美国</b></li>
                            <li><b> CA => 加拿大</b></li>
                        </ul>
                    </div>
                    <div class="form-group">
                        <label for="recipient-name" class="control-label"></label>
                        <input type="file" id="excel-ceping" name="file" class="form-control">
                    </div>
                    <input type="hidden" name="operator_id"  value="<?= $this->_user->id ?>">
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="button" id="import-confirm" class="btn btn-primary">确认导入</button>
                </div>
            </div>
        </form>
    </div>
</div>

<!-- loading层 -->
<style>
    .loading-x{
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: #0000008a;
        z-index: 20050;
    }
    .x-contain{
        margin: 18%;
        text-align: center;
    }
</style>
<div class="loading-x">
    <div class="x-contain">
        <img src="/static/assets/26073943_nCX5.gif" alt="">
    </div>
</div>

<script>
    $('#import-confirm').click(function () {
        $('.loading-x').show();
        var excel = $('#excel-ceping')[0].files[0];
        var formData = new FormData();
        // return;
        formData.append("file",excel);
        formData.append("operator_id","<?= $this->_user->id ?>");
        setTimeout(function () {
            $.ajax({
                url:"<?= site_url('tasks/taskoperate/pythonImportExcel') ?>",
                dataType:'json',
                type:'POST',
                async: false,
                data: formData,
                processData : false, // 使数据不做处理
                contentType : false, // 不要设置Content-Type请求头
                success: function(res){
                    console.log(res);
                    $('.loading-x').fadeOut();
                    if (res.status){
                        $('#importModal').modal('hide');
                        toastr.success(res.msg);
                        setTimeout(function () {
                            location.reload();
                        },1000)
                    } else {
                        toastr.error(res.msg)
                    }
                },
                error:function(res){
                    console.log(res);
                    $('.loading-x').fadeOut();
                    toastr.error('网络错误，请稍后重试！');

                }
            });
        },100)


    })
</script>

<div class="modal fade bs-example-modal-lg" id="process" data-backdrop="static" style="margin-top: 20%" tabindex="-1"
     role="dialog" aria-labelledby="myLargeModalLabel">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">

            <div class="progress progress-striped active" style="height: 20px;">
                <div class="progress-bar progress-bar-info" style="width:0;" role="progressbar" aria-valuenow="0"
                     aria-valuemax="100" aria-valuemin="0" id="show-process">0%
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">

    function defAjaxConfirm(url) {
        if (!confirm("确定要删除吗？")) {
            return false;
        }
        return true;
    }

    $(document).ready(function () {
        $('.img-rounded').zoomify();
    });

    $('#ajax_merge').click(function () {
        var data = $('#ajax_merge_form').serialize();
        if (!data) {
            toastr.error('请选择要合并的测评记录', '失败');
            return;
        }

        $.ajax({
            url: '<?=site_url("/tasks/taskrecorditem/group_cepings")?>',
            data: data,
            method: 'POST',
            dataType: 'json',
            success: function (data) {
                if (data.status) {
                    toastr.success(data.msg, '成功');
                    setTimeout(function () {
                        location.href = '<?=site_url("/finance/apply/add");?>';
                    }, 1000)
                } else {
                    toastr.error(data.msg, '失败')
                }
            },
            fail: function (e) {
                toastr.error(data.msg, '失败')
            }
        })
    });

    $('#ajax_delete').click(function () {
        var data = $('#ajax_merge_form').serialize();
        if (!data) {
            toastr.error('请选择要删除的测评记录', '失败');
            return;
        }
        if(!defAjaxConfirm()){
            return
        }

        $.ajax({
            url: '<?=site_url("/tasks/taskrecorditem/group_delete")?>',
            data: data,
            method: 'POST',
            dataType: 'json',
            success: function (data) {
                console.log(data)
                if (data.status) {
                    toastr.success(data.msg, '成功');
                    setTimeout(function () {
                        location.reload()
                    }, 1000)
                }else {
                    toastr.error(data.msg, '失败')
                }
            },
            fail: function (e) {
                toastr.error(data.msg, '失败')
            }
        })
    });

    $('#merge_all').click(function () {
        if ($(this).prop("checked") == true) {
            $(".mbox").prop('checked', true);
            $(".mbox").parent('span').addClass('checked');
            return;
        } else {
            $(".mbox").prop('checked', false);
            $(".mbox").parent('span').removeClass('checked');
            return;
        }
    });
</script>
<!-- END PAGE CONTENT-->
